import json
import os
import sys

tolerance = {
    "H": 10,
    "S": 10,
    "L": 10
}

if __name__ == '__main__':


    # 从文件读取json
    # https://www.cnblogs.com/CircleWang/p/15270974.html
    with open('test.json', 'r', encoding='utf-8') as json_f:
        imgData = json.load(json_f)

    # 输出格式化
    # print(json.dumps(imgData, indent=2, ensure_ascii=False))

    # 处理数据
    for i, line_1 in enumerate(imgData):
        for px_1_i, px_1 in enumerate(line_1):
            print(px_1)

            # 当前行剩余列数
            n_x = len(line_1) - px_1_i - 1
            # 剩余行数
            n_y = len(imgData) - i - 1

            # 修正后的内层循环
            for j in range(n_y):
                for px_2_i in range(n_x):
                    # 正确计算目标位置：当前像素的右下区域
                    # 从下一行开始
                    target_i = i + j + 1
                    # 从下一列开始
                    target_j = px_1_i + 1 + px_2_i
                    # print(f'[{target_i}][{target_j}]')
                    px_2 = imgData[target_i][target_j]
                    print(px_2)

    # print(sys.argv)
